package com.example.mapper.dao;

import com.example.entity.farm.PlayerFarm;
import com.example.entity.farm.TaskFarm;
import com.example.entity.farm.dto.StockPlayerFarmDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface FarmDao {

    @Select("select * from playerFarm where uid=#{uid}")
    PlayerFarm selectPlayerFarmByUid(String uid);

    @Update("update playerFarm set fertilizer=#{fertilizer} where uid=#{uid}")
    void updatePlayerFarmFertilizer(String uid,Integer fertilizer);

    @Update("update playerFarm set progress=#{progress} where uid=#{uid}")
    void updatePlayerFarmProgress(String uid,Integer progress);

    @Update("update playerFarm set isWater=1 where uid=#{uid}")
    void water(String uid);

    @Select("select uid,itemID,progress,fertilizer,isWater from playerFarm where uid=#{uid}")
    PlayerFarm desc(String uid);

    @Select("select * from taskFarm where uid=#{uid}")
    List<TaskFarm> task(String uid);

    @Select("select count(uid) from playerFarm where uid=#{uid} ")
    int selectIsFarm(String uid);

    @Select("select count(itemId) from freeItem where itemId=#{itemId}")
    int isFreeItem(String itemId);

    @Insert("insert into playerFarm(uid,itemID,progress,fertilizer,isWater) values(#{uid},#{itemId},0,0,0)")
    int goFarm(String uid,String itemId);
}
